#include "Shape.h"

using namespace PHYOgre;


Box::Box(const Vector3& iPosition,const Vector3* iCorners)
{
	for (int i = 0 ; i < 8; ++i)
	{
		mVertices[i] = iCorners[i];
	}
}
Box::Box(const Vector3& iPosition,const Vector3& iHalfSize)
	:mPosition(iPosition)
	,mHalfSize(iHalfSize)
{
	//TODO: check 
	mVertices[0] = Vector3(-mHalfSize.x, -mHalfSize.y, -mHalfSize.z);
	mVertices[1] = Vector3(-mHalfSize.x, -mHalfSize.y, mHalfSize.z);
	mVertices[2] = Vector3(-mHalfSize.x, mHalfSize.y, -mHalfSize.z);
	mVertices[3] = Vector3(-mHalfSize.x, mHalfSize.y, mHalfSize.z);
	mVertices[4] = Vector3(mHalfSize.x, -mHalfSize.y, -mHalfSize.z);
	mVertices[5] = Vector3(mHalfSize.x, -mHalfSize.y, mHalfSize.z);
	mVertices[6] = Vector3(mHalfSize.x, mHalfSize.y, -mHalfSize.z);
	mVertices[7] = Vector3(mHalfSize.x, mHalfSize.y, mHalfSize.z);

}
void Box::Transform(const Matrix4& iMat)
{
	for (int i = 0 ; i < 8; ++i)
	{
		mVertices[i] = iMat * mVertices[i];
	}

}
ShapeType Box::GetType() const
{
	return BOX;
}
void Box::Translate(const Vector3& iTranslation)
{
	for (int i = 0 ; i < 8; ++i)
	{
		mVertices[i] += iTranslation;
	}

}
void Box::Rotate(const Quaternion& iRotation)
{
	for (int i = 0 ; i < 8; ++i)
	{
		mVertices[i] = iRotation * mVertices[i];
	}
}
		

Sphere::Sphere(const Vector3& iPosition, const Real& iRadius)
	:mPosition(iPosition)
	,mRadius(iRadius)
{

}
ShapeType Sphere::GetType() const
{
	return SPHERE;
}

void Sphere::Transform(const Matrix4& iMat)
{
	mPosition = iMat * mPosition;
}

void Sphere::Translate(const Vector3& iTranslation)
{
	for (int i = 0 ; i < 8; ++i)
	{
		mPosition += iTranslation;
	}

}
void Sphere::Rotate(const Quaternion& iRotation)
{
	
}


Plane::Plane(const Vector3& iNormal,const Vector2& iSize, const Real& iOffset )
	:mNormal(iNormal)
	,mSize(iSize)
	,mOffset(iOffset)
{

}
ShapeType Plane::GetType()const
{
	return PLANE;
}

void Plane::Transform(const Matrix4& iMat)
{
	mNormal = iMat * mNormal;
}

void Plane::Translate(const Vector3& iTranslation)
{
	

}
void Plane::Rotate(const Quaternion& iRotation)
{
	
}